<template>
    <div>
        <div class="showMyBlog" id="Blog">
            {{node}}
        </div>
    </div>
</template>

<script>
var showdown  = require('showdown');
var    converter = new showdown.Converter();

export default {

  data () {
    return {
      
    }
  },
  
  created(){
      //获取文章id
      let id = this.$route.params.id;
      if(id != null){
          this.$store.dispatch('getNode', id);
      }
      
  },
  computed:{
      node(){
          //文章内容初始为null  当数据更改 node内容发生更改 本函数再次被调用 填充dom
          var blog = document.getElementById("Blog");
          var text = this.$store.getters.getNode;
          if(text != null){
              blog.innerHTML=converter.makeHtml(text);
          }
          return this.$store.getters.getNode
      }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style >
.showMyBlog{
    margin-top: 30px;
}
.showMyBlog body {
  color: #444;
  font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
  font-size: 13px;
  line-height: 1.5em;
  padding: 1em;
  margin: auto;
  max-width: 42em;
  background: #fefefe;
}
.showMyBlog h1,
.showMyBlog h2,
.showMyBlog h3,
.showMyBlog h4,
.showMyBlog h5,
.showMyBlog h6 {
  font-weight: bold;
}
.showMyBlog h1 {
  color: #000000;
  font-size: 28px;
}
.showMyBlog h2 {
  border-bottom: 2px solid #CCCCCC;
  color: #000000;
  font-size: 24px;
}
.showMyBlog h3 {
  border-bottom: 2px solid #CCCCCC;
  font-size: 18px;
}
.showMyBlog h4 {
  font-size: 16px;
}
.showMyBlog h5 {
  font-size: 14px;
}
.showMyBlog h6 {
  color: #777777;
  background-color: inherit;
  font-size: 14px;
}
.showMyBlog hr {
  height: 0.2em;
  border: 0;
  color: #CCCCCC;
  background-color: #CCCCCC;
}
.showMyBlog p,
.showMyBlog blockquote,
.showMyBlog ul,
.showMyBlog ol,
.showMyBlog dl,
.showMyBlog li,
.showMyBlog table,
.showMyBlog pre {
  margin: 15px 0;
}
.showMyBlog p {
  margin: 1em 0;
}
.showMyBlog pre {
  background-color: #F8F8F8;
  border: 1px solid #CCCCCC;
  border-radius: 3px;
  overflow: auto;
  padding: 5px;
}
.showMyBlog pre code {
  background-color: #F8F8F8;
  border: none;
  padding: 0;
}
.showMyBlog code {
  font-family: Consolas, Monaco, Andale Mono, monospace;
  background-color: #F8F8F8;
  border: 1px solid #CCCCCC;
  border-radius: 3px;
  padding: 0 0.2em;
  line-height: 1;
}
.showMyBlog pre > code {
  border: 0;
  margin: 0;
  padding: 0;
}
.showMyBlog a {
  color: #0645ad;
  text-decoration: none;
}
.showMyBlog a:visited {
  color: #0b0080;
}
.showMyBlog a:hover {
  color: #06e;
}
.showMyBlog a:active {
  color: #faa700;
}
.showMyBlog a:focus {
  outline: thin dotted;
}
.showMyBlog a:hover,
.showMyBlog a:active {
  outline: 0;
}
.showMyBlog ::-moz-selection {
  background: rgba(255, 255, 0, 0.3);
  color: #000;
}
.showMyBlog ::selection {
  background: rgba(255, 255, 0, 0.3);
  color: #000;
}
.showMyBlog a::-moz-selection {
  background: rgba(255, 255, 0, 0.3);
  color: #0645ad;
}
.showMyBlog a::selection {
  background: rgba(255, 255, 0, 0.3);
  color: #0645ad;
}
.showMyBlog blockquote {
  color: #666666;
  margin: 0;
  padding-left: 3em;
  border-left: 0.5em #EEE solid;
}
.showMyBlog ul,
.showMyBlog ol {
  margin: 1em 0;
  padding: 0 0 0 2em;
}
.showMyBlog li p:last-child {
  margin: 0;
}
.showMyBlog dd {
  margin: 0 0 0 2em;
}
.showMyBlog img {
  border: 0;
  -ms-interpolation-mode: bicubic;
  vertical-align: middle;
  max-width: 100%;
}
.showMyBlog table {
  border-collapse: collapse;
  border-spacing: 0;
}
.showMyBlog td {
  vertical-align: top;
}
@media only screen and (min-width: 480px) {
  .showMyBlog body {
    font-size: 14px;
  }
}
@media only screen and (min-width: 768px) {
  .showMyBlog body {
    font-size: 16px;
  }
}

</style>